<?php

use yii\helpers\Html;
use yii\grid\GridView;
use yii\web\View;

/* @var $this yii\web\View */
/* @var $searchModel app\models\DormchangeinfoSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = '宿舍变动信息';
$this->params['breadcrumbs'][] = $this->title;

//导出excel所需：：：：：：：：
$js=<<< Js
var exportLink = document.getElementById('export');
	exportLink.addEventListener('click', function(e){
		e.preventDefault();
		if(e.target.nodeName === "A"){
			tableExport('table-export', '导出文件', e.target.getAttribute('data-type'));
		}
	}, false);
Js;
$this->registerJs($js, View::POS_END, 'myAjax');
?>
<script src="<?= \Yii::getAlias('@web')?>/js/Blob.js"></script>

<script src="<?= \Yii::getAlias('@web')?>/js/FileSaver.js"></script>

<script src="<?= \Yii::getAlias('@web')?>/js/tableExport.js"></script>


<div class="dormchangeinfo-index">
    <p>
        <?= Html::a('添加', ['create'], ['class' => 'btn btn-success']) ?>
<!--         导出按钮 -->
      <div id="export" style="float: left;margin-right: 4px;" ><a class="btn btn-info"  data-type="xls" href="javascript:;">导出excel</a></div>
    <div id="import" ><a class="btn btn-info"  data-type="xls" href="<?=Yii::getAlias('@web'.'/dormchangeinfo/import')?>">导入excel</a></div>
   </p>
    
    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
    		
    		//导出excel所需 ：设置表id
    		'tableOptions'=>[
    				'id'=>'table-export',
    				'class' => 'table table-striped table-bordered',
    		],
        'columns' => [
            ['class' => 'yii\grid\SerialColumn'],
            'stu_id',
            'stu_name',
            'time',
            'type'=>[
            	'attribute'=>'type',
            		'filter'=>['外宿'=>'外宿','申请住宿'=>'申请住宿','调整宿舍'=>'调整宿舍','入学分配'=>'入学分配','离校回收'=>'离校回收']
    		],
            
            'before_floor',
        		'before_num',
            
            'after_floor',
        		'after_num',
            'remark',

            ['class' => 'yii\grid\ActionColumn'],
        ],
    ]); ?>
</div>
